SUBROUTINE set_param
USE param
USE global
IMPLICIT NONE
INTEGER :: i,j,k,l,n

! Lattice parameters
SELECT CASE(ltype)
CASE(1)
   nbasis=2
   ALLOCATE(basis(nbasis,3))
   basis(1,1)=0.0
   basis(1,2)=0.0
   basis(1,3)=0.0
   basis(2,1)=0.5
   basis(2,2)=0.5
   basis(2,3)=0.5
   n_neighbor=3*3*3*nbasis
   allocate(neighbor_lattice(n_neighbor))
CASE(2)
   nbasis=4
   ALLOCATE(basis(nbasis,3))
   basis(1,1)=0.0
   basis(1,2)=0.0
   basis(1,3)=0.0
   basis(2,1)=0.5
   basis(2,2)=0.5
   basis(2,3)=0.0
   basis(3,1)=0.5
   basis(3,2)=0.0
   basis(3,3)=0.5
   basis(4,1)=0.0
   basis(4,2)=0.5
   basis(4,3)=0.5
   n_neighbor=3*3*3*nbasis
   allocate(neighbor_lattice(n_neighbor))
CASE DEFAULT
   STOP 'ERR:make_lattice-Unallowable lattice type'
END SELECT

n=0
do k=-1,1
   do j=-1,1
      do i=-1,1
         do l=1,nbasis
            n=n+1
            neighbor_lattice(n)%px=(i+basis(l,1))*dist_a0_ang
            neighbor_lattice(n)%py=(j+basis(l,2))*dist_a0_ang
            neighbor_lattice(n)%pz=(k+basis(l,3))*dist_a0_ang
         end do
      end do
   end do
end do

! allocate layer index to remove
IF(n_rlayer.GT.0) THEN
   ALLOCATE(remove_layer1(n_rlayer))
   ALLOCATE(remove_layer2(n_rlayer))
END IF

! Set layer index to remove
DO i=1,n_rlayer
   remove_layer1(i)=i-1
   remove_layer2(i)=nside_int-i
END DO

1000 FORMAT(3X,'Number of layers to be removed: ',I1)
OPEN(UNIT=1,FILE=lgfn,STATUS='OLD',ACCESS='APPEND')
WRITE(1,1000) n_rlayer
PRINT 1000,n_rlayer
CLOSE(1)

END SUBROUTINE set_param
